package com.evl.core.weixin;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

import org.apache.commons.io.IOUtils;

public class HttpService {

    private static final int TIMEOUT = 30000;

    public static String doGet(String url){
        InputStream in = null;
        try {
            URL u = new URL(url);
            URLConnection conn = u.openConnection();
            conn.setConnectTimeout(TIMEOUT);
            conn.setReadTimeout(TIMEOUT);
            in = conn.getInputStream();

            InputStreamReader inputStreamReader = new InputStreamReader(in, "utf-8");
            return IOUtils.toString(inputStreamReader);
        } catch (IOException e) {
            return null;
        } finally {
            IOUtils.closeQuietly(in);
        }
    }

}
